//
//  DUYearCalView.swift
//  SimpleCal
//
//  Created by 杜晓祥 on 2021/11/19.
//

import Cocoa

class DUYearCalView: NSView {
    
    private var calView = [DUPopMonthView]()

    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        initialize()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        initialize()
    }
    
    private func initialize() {
        for i in (0...3) {
            for j in (0...2) {
                let x = j*210+j*20+10
                let y = (3-i)*230+(3-i)*20+15
                let cbox = DUPopMonthView(frame: NSRect(x: x, y: y, width: 210, height: 230))
                cbox.enableAll = false
                calView.append(cbox)
                self.addSubview(cbox)
            }
        }
    }
    
    func update(year:Int) {
        for i in (1...12) {
            calView[i - 1].setDate(year: year, month: i)
        }
    }
    
    
    @IBInspectable var year:Int = 0 {
        didSet {
            if year != 0 {
                update(year: year)
            }
        }
    }
}
